1. Statement of the Technical Field
The present invention relates to the field of object state persistence and more particularly to many-to-many relationship management in an object persistence management system.
2. Description of the Related Art
As object-oriented technology has matured, it has proven to be an excellent solution for modeling problems, building prototypes, and rapidly deploying applications. Though object models for applications are often reused in other applications, one of the costlier tasks of development has been that of translating between object-oriented and non-object-oriented representations of application models. Consequently, the task of mapping objects both to non object oriented relational database tables and other non object oriented data sources has been the missing piece in object persistence management.
Conventional object persistence management systems typically include a collection of development browsers, tools, and code generation services that assist in the development of persistence support within object-oriented applications. Browsers are the main resources for building applications using the persistence management framework. In particular, browsers are used to describe object models, database schema, and data store mappings, as well as to generate source code need by the framework to manage objects in the model. Conventional object persistence management systems can include several browsers, including object model browsers, schema browsers and map browsers.
Object browsers can be used to define object models, its classes and associations. Schema browsers, by comparison, can be used to define a logical description of the data store to which the object model will persist. Importantly, map browsers can be used to map the object model, or persistent classes, to the logical, database schema. In particular, each persistent class requires a map which associates the attributes of the class with their corresponding columns or fields in the database tables or records thereof.
In that regard, present object persistence management systems provide for one-to-one, one-to-many and many-to-many relationship management. In the case of one-to-one and one-to-many relationship management, present object persistence management systems provide decentralized, loosely coupled agents, referred to herein as “links”, to manage each side of the relationship. In particular, each link manages the state of an object in the relationship and coordinates with a corresponding “counter-link” when necessary, as is well-known in the art.
Part of the relationship management process can include the management of the persistent state of the relationship. The management of the persistent state of the relationship can be relatively straightforward in the case of one-to-one and one-to-many relationships since the state of the relationship can be included as part of the state of the related objects themselves. Hence, if the links have correctly managed the related objects, when the objects are stored to an underlying database, the state of the relationship also will be stored.
A typical method used to store or persist the state of objects and their relationships in a one-to-one or one-to-many relationship can include using tables in a relationship database—one for each object in the relationship. In each table, a particular field can be used as a state reference in the other tables. For example, consider an object model of a class and an instructor having a one-to-one relationship with one another. A table can be constructed for all possible instructors, each instructor having a unique ID. A corresponding table can be constructed for all classes, each class having a reference to the unique ID of its instructor.
In this example, the values for the class reference to a unique instructor ID can dynamically change according to the state of the associated class and instructor objects at the time those objects are stored in the database. If the relationship management system correctly maintains the state of the related objects as their relationships change, then the relationships can be correctly stored to the underlying database when the objects are saved to a data store. If the saved objects are later restored from the data store, then the relationships also can be correctly restored.
Unlike one-to-one and one-to-many relationships, storing the state of many-to-many relationships is not as straightforward. This is so because a third, auxiliary table, referred to hereinafter as a “junction table”, typically is required to store the relationship information. For example, if multiple students are enrolled in multiple classes in an instructor-class-student model, a many-to-many relationship will have been created as between the students and their respective classes in which they are enrolled.
In consequence, a junction table unrelated to any particular object will be required in order to track those students enrolled in the multiplicity of classes at any one time. Specifically, each record in the junction table can include two fields linking the unique ID of a student with the unique ID of a class in which the student is enrolled. These records typically are referred to as “key-pair entries”. Of course, the junction table can include multiple key-pair entries for each student, each key-pair entry reflecting only one of the several classes in which the student may be enrolled.
Since the management of many-to-many relationships requires the management of a third, auxiliary entity apart from the related entities, the links managing the relationship between the related objects must be concerned not only with the state of the related objects, but also with the state of the third, auxiliary entity. One common approach to solving the problem of managing the junction table includes introducing a relationship manager responsible for updating key-pair entries in the junction table. As links to either side of the relationship detect relationship changes, the links inform the relationship manager of the change. In consequence, the relationship manager can ensure that the junction table has been updated accordingly.
Significantly, the common solution to managing many-to-many relationships in an object model can require the addition of substantial infrastructure to the run-time portion of the object persistence management system. This is so because typical object persistence management systems are designed such that only application entities such as the links provide state data to be flushed to the database. Conversely, only application entitles can be retrieved from the database. The relationship manager, however, is not an application entity. Rather, the relationship manager merely is an artifact required to record the relationship state for many-to-many associations.
The decentralization of the management of the junction table, heretofore, has been complicated by potential conflicts which can arise when persisting state changes in related objects to their associated object tables. For instance, links typically can buffer state changes prior to their persistence in a table. When buffering the addition of a relationship, the link can buffer the operation, “add [key-pair entry]”. Conversely, when buffering the removal of a relationship, the link can buffer the operation, “remove [key-pair entry]”.
In both cases, however, it is possible that a corresponding link which manages the other portion of the relationship also can buffer the management operations pertaining to the key-pair entry. Specifically, it is possible that one link which manages the state of object1 buffers the operation, “add [object1, object2]”, while the link which manages the state of object 2 buffers the operation, “remove[object1, object2]. When persisting the state of object1 and object 2, however, the timing of performing each buffered operation can undermine the integrity of the junction table.
Specifically, where the buffered operations of the link which manages object 2 are performed prior to the buffered operations of the link which manages object1, a conflict can arise. In consequence, despite the apparent disadvantages of the centralized management of the junction table, the relationship manager can be required to avoid such conflicts. Thus, there exists a need for a many-to-many relationship management system in which timing conflicts can be managed notwithstanding the absence of a centralized relationship manager.